﻿using MediatR;
using Production_Get.API.Infrastructures.Interfaces;
using Return.Enum;
using THE_WIND_RISES.Common.Domans.Produce.Order;
using THE_WIND_RISES.Common.Dtos;

namespace Production_Get.API.Application.Commands.OrderShow
{
    /// <summary>
    /// 销售订单类型列表
    /// </summary>
    public class OrdersTypeScretenHandler : IRequestHandler<OrdersTypeScretenCommend, Result>
    {
        private readonly IBaseRepositoryGet<OrdersType> OrdersType;

        public OrdersTypeScretenHandler(IBaseRepositoryGet<OrdersType> OrdersType)
        {
            this.OrdersType = OrdersType;
        }

        public async Task<Result> Handle(OrdersTypeScretenCommend request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCodes.Search };

            string sql = "SELECT * FROM OrdersType";
            var list = OrdersType.GetAll(sql, default).ToList();
            if (list != null)
            {
                result.Code = (int)CommonErrorCodes.Success;
                result.Data = list;
                result.Msg = "显示成功";
            }

            return result;
        }
    }
}
